﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ESpace.DalTools
{
	public partial class Encrypt : Form
	{
		public Encrypt()
		{
			InitializeComponent();
		}

		private void btnEncrypt_Click(object sender, EventArgs e)
		{
			Alogrim objAlogrim = null;
			if (ddlEncryptType.SelectedIndex == 0)
				objAlogrim = new Alogrim(Alogrim.SymmProvEnum.DES);
			else if (ddlEncryptType.SelectedIndex == 1)
				objAlogrim = new Alogrim(Alogrim.SymmProvEnum.RC2);
			else if (ddlEncryptType.SelectedIndex == 2)
				objAlogrim = new Alogrim(Alogrim.SymmProvEnum.Rijndael);
			else if (ddlEncryptType.SelectedIndex == 3)
				objAlogrim = new Alogrim(Alogrim.SymmProvEnum.TripleDES);

			objAlogrim.Key = txtKey.Text;
			objAlogrim.IV = txtIV.Text;
			txtDesc.Text = objAlogrim.Encrypting(txtSource.Text);
			txtDescEncode.Text = System.Web.HttpUtility.UrlEncode(txtDesc.Text);

			DialogResult = DialogResult.None;
		}

		private void btnClose_Click(object sender, EventArgs e)
		{
			this.Close();
		}
	}
}